package leetcode;

import stack.Stack;

public class MinStack {
  private Stack<Integer> element=new Stack<>();
  private  Stack<Integer> support=new Stack<>();
        public MinStack() {

        }
        public void push(int x) {
            element.push(x);
            if(support.isEmpty()){
                support.push(x);
        }else{
                int tmp=support.peek();
                int min=Math.min(x,tmp);
                support.push(min);
            }
        }
        public void pop() {
                support.pop();
                element.pop();
        }
        public int top() {
       return element.peek();
        }

        public int getMin() {
      return support.peek();
        }

}
